package com.tj.admin.auth.server.services;

import com.fqgj.common.api.Page;
import com.fqgj.common.utils.TimeUtils;
import com.tj.admin.auth.domain.Admin;
import com.tj.admin.auth.server.dao.AdminDao;
import com.tj.admin.auth.server.dao.AdminTokenDao;
import com.tj.admin.auth.server.entity.AdminEntity;
import com.tj.admin.auth.server.entity.AdminTokenEntity;
import com.tj.admin.auth.service.AdminService;
import com.tj.admin.auth.vo.AdminVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: binary (mr.vencnet@gmail.com)
 * Date: 2020-08-11
 * Time: 10:37
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDao adminDao;

    @Autowired
    private AdminTokenDao adminTokenDao;

    @Override
    public Boolean registration(Admin admin) {
        return null;
    }

    @Override
    public Admin getOneAdminByAccount(String account) {
        AdminEntity adminEntity = adminDao.selectOneByAccount(account);
        if (adminEntity == null) {
            return null;
        }

        // TODO: 2020-08-11
        return new Admin().setId(adminEntity.getId())
                .setPassword(adminEntity.getPassword());
    }

    @Override
    public Boolean add(Admin admin, List<Long> roleIds, String productCode, List<String> productCodeList) {
        return null;
    }

    @Override
    public Boolean update(Admin admin, List<String> list) {
        return null;
    }

    @Override
    public Boolean updateAdminStatus(Long adminId, Integer adminStatus) {
        return null;
    }

    @Override
    public Boolean updateAdminPassword(Long adminId, String password) {
        return null;
    }

    @Override
    public Boolean deleteAdmin(Long adminId) {
        return null;
    }

    @Override
    public Admin getByAccessToken(String accessToken) {
        // TODO: 2020-08-11
        AdminTokenEntity adminTokenEntity = adminTokenDao.selectByToken(accessToken);
        if (adminTokenEntity == null) {
            return null;
        }

        return new Admin().setId(adminTokenEntity.getId());
    }

    @Override
    public void addNewAccessToken(int id, String token) {
        AdminTokenEntity adminTokenEntity = new AdminTokenEntity()
                .setAccessToken(token)
                .setAdminId(id)
                .setExpireDate(TimeUtils.appointed(2));

        adminTokenDao.insert(adminTokenEntity);
    }

    @Override
    public List<Admin> getAdminListByIdList(List<Long> adminIdList) {
        return null;
    }

    @Override
    public List<Admin> getAdminListByIdList(List<Long> adminIdList, String merchantCode) {
        return null;
    }

    @Override
    public List<Admin> getAdminListByIdListAndProductType(List<Long> adminIdList, String productType) {
        return null;
    }

    @Override
    public List<Long> getMenuIdsByAdminId(Long adminId) {
        return null;
    }

    @Override
    public Admin getOneAdminByAdmin(Long adminId) {
        return null;
    }

    @Override
    public AdminVo fillAuditProfile(AdminVo adminVo) {
        return null;
    }

    @Override
    public AdminVo fillCollectionProfile(AdminVo adminVo) {
        return null;
    }
}
